<template>
  <div>
    <h3>testStore组件：演示store的用法</h3>
    <el-button type="primary" @click="getAsyncData">获取dispatch后的count</el-button>
  </div>
</template>
<script>
import { useStore } from 'vuex'
export default {
  name: 'testStore',
  setup() {
    const store = useStore()
    console.log('store.state.count', store.state.count)
    console.log('store.getters.doubleCount', store.getters.doubleCount)
    store.commit('increcement', 20)
    console.log('store.state.count', store.state.count)
    store.dispatch('getCountAsync', 30)
  },
  methods: {
    getAsyncData() {
      // 注意store在方法和setup里获取的差异
      console.log('store.state.count', this.$store.state.count)
    },
  },
}
</script>